﻿using Microsoft.Xna.Framework.Content;
using System.Xml.Serialization;
using Microsoft.Xna.Framework.Audio;
using System;

namespace Tomahawk.Resources.Audio
{
    public class AudioBankReader : ContentTypeReader<AudioBank>
    {
        #region Properties
        public delegate bool InitAudioBankDelegate(AudioBank audioBank);
        public static event InitAudioBankDelegate OnInitAudioBank;
        #endregion

        protected override AudioBank Read(ContentReader input, AudioBank existingInstance)
        {
            AudioBank output = null;

            XmlSerializer x = new XmlSerializer(typeof(AudioBank));
            output = (AudioBank)x.Deserialize(input.BaseStream);

            if (OnInitAudioBank != null)
            {
                OnInitAudioBank(output);
            }

            return output;
        }
    }
}
